﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Hdt.TransOcean.Dal;

namespace Hdt.TransOcean.Presentation
{
    public partial class FormLogin : DevExpress.XtraEditors.XtraForm
    {
        public bool IsLoggedIn
        {
            get;
            set;
        }
        public FormLogin()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            

            User user = new User();
            user.code = txtUseName.Text;
            user.password = Common.GetMd5Hash(txtPassword.Text.ToString());
            if (Dao.Login(user))
            {
                IsLoggedIn = true;
                GlobalVariable.loginUser = user;
                this.Close();
            }
            else
            {
                MessageBox.Show("Sai Tên đăng nhập hoặc Mật khẩu", "Đăng nhập");
            }
                
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}